package com.ksy.common.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ksy.common.R;


/**
 * Created by Ksy.
 */

public class ErrorView extends LinearLayout {

    private TextView emptyText;

    public ErrorView(Context context) {
        this(context, null);
    }

    public ErrorView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.common_layout_error, this, true);
    }

    public void showMsg(String msg) {
        if (emptyText == null) {
            emptyText = findViewById(R.id.emptyText);
        }
        if (TextUtils.isEmpty(msg)) {
            msg = "暂无数据";
        }
        emptyText.setText(msg);
    }
}
